/**
 *
 * @author spider
 * 
 */
package br.unb.utils;

import java.util.MissingResourceException;
import java.util.ResourceBundle;


public class Resource {

    public Resource() {
        Console.println("Resource() <init>");
    }
    /**Files containing user interface strings, buttons toolbars etc*/
    public static final ResourceBundle ControlComponent = getResource("resources.userInterface.ControlComponent");
    public static final ResourceBundle InferenceFrame = getResource("resources.userInterface.InferenceFrame");
    public static final ResourceBundle Sync = getResource("resources.userInterface.Sync");
    public static final ResourceBundle GraphicInterface = getResource("resources.userInterface.GraphicInterface");
    public static final ResourceBundle QosChart = getResource("resources.userInterface.QosChart");
    public static final ResourceBundle QosPanel = getResource("resources.userInterface.QosPanel");
    public static final ResourceBundle CommunicPanel = getResource("resources.userInterface.CommunicPanel");
    public static final ResourceBundle InferenceDataImporter = getResource("resources.userInterface.InferenceDataImporter");
    public static final ResourceBundle TrafficTable = getResource("resources.userInterface.TrafficTable");
    public static final ResourceBundle NewTrafficPanel = getResource("resources.userInterface.NewTrafficPanel");
    public static final ResourceBundle Start = getResource("resources.userInterface.Start");
    /**Messages*/
    /*DONE fix this class so that all the ResourceBundles above handle the erros here
    and the does not throw exceptions anywhere else*/
    private static ResourceBundle getResource(String resourceName) {
        try {
            return java.util.ResourceBundle.getBundle(resourceName);
        } catch (MissingResourceException exception) {
            exception.printStackTrace();
            System.err.println(resourceName + ".properties not found");
            System.exit(1);
        }
        return null;/*DUMMY, must exit() on exception above*/
    }

    /*Strings of the program are found in a single file loaded below*/
    public static String getString(String key) {
        try {
            if (false) {//debug
                return java.util.ResourceBundle.getBundle("resources.messages").getString(key)
                        + " ";
            } else {
                return key + " ";
            }
        } catch (MissingResourceException exception) {
            //System.err.println(key + " not found");
            //System.exit(1); //too dramatic, commented
            return key + " ";
        }
    }
}
